<?php
ob_start();
include 'common/header.html';
include 'common/left.html';
include 'class/Member.php';
include 'common/area.inc.php';
include_once '/var/www/html/new/d/class/abc/Member.class.php';

$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));

if(isset($_REQUEST['sync']) && $_REQUEST['sync']==1){// 异步获取转分销产品
	
	ob_end_clean();
	$mem = new Member($s, $_SESSION['memberID']);
    $prods[1]=$mem->salePros();// 获取门票
    $tmp = $save = $ticket = array();
    $fids = array();
    $count = 0;
    $Y_m_d = date('Y-m-d');

	$dname = abc777\Member::Supplier();
	print_r($prods[1]);
	foreach($prods[1] as $k=>$val){
		if($val['apply_did']==$_SESSION['sid']) continue;
		if($val['pay']=='0' && !$saleScene) continue;
		if(!isset($dname[$val['sapply_did']])) continue;// 供应商断开关系不应该能销售
		
		$xml = $s->Dynamic_Price_And_Storage($_SESSION['saccount'],$val['pid'],$Y_m_d,1,0,0,$val['sapply_did']);
		if($xml==105) $xml = $s->Dynamic_Price_And_Storage($_SESSION['saccount'],$val['pid'],$Y_m_d,2,0,0,$val['sapply_did']);   
		if ($xml==105)  continue;
		$jsprice=(int)simplexml_load_string($xml)->Rec->UUsprice;
		$xml = $s->Dynamic_Price_And_Storage($_SESSION['saccount'],$val['pid'],$Y_m_d,1,1,0,$val['sapply_did']);
		if($xml==105) $xml = $s->Dynamic_Price_And_Storage($_SESSION['saccount'],$val['pid'],$Y_m_d,2,1,0,$val['sapply_did']);
		if ($xml==105) continue;
		
		$uprice=(int)simplexml_load_string($xml)->Rec->UUsprice;
		if(!isset($save[$val['lid']])){
	
			$tmp['title'] = $val['title'];
			$tmp['lid']   = $val['lid'];
			
			// 拆分地区
			$areas_split = explode('|',$val['area']);
			$tmp['province']=$areas[$areas_split[0]];
			$tmp['city']=$areas[$areas_split[1]];
			$fids[$val['sapply_did']]=$val['sapply_did'];
			
			$save[$val['lid']]=$tmp;
			$count = $count + 1;
		}

		$ticket['tid']=$val['tid'];
		$ticket['aid']=$val['sapply_did'];
		$ticket['pid']=$val['pid'];
		$ticket['title']=$val['ttitle'];
		$ticket['jsprice']= $jsprice;
		$ticket['uprice'] = $uprice;
		$ticket['dname'] = $dname[$val['sapply_did']];
		$save[$val['lid']]['ticket'][$val['tid']][]=$ticket;

	}
	print_r($save);
	exit;

    $prods[1]=$save;

    $response = array(
        'total'=>$count,
        'code'=>200,
        'lists'=>$save
    );
    
    echo json_encode($response);
    exit;
}


include('tpl/prod_sale_today.html');
include('common/footer.html');
?>

